#ifndef ALL_H
#define ALL_H

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/in.h>
#include <pthread.h>
#include <net/ethernet.h>
#include <string.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <netpacket/packet.h>

#define buflen 1024//一般数据长度
#define maxinterfaces 10//接口最大数量

struct mac_hread
{
    unsigned char dest_mac[6];//目标mac地址--destination mac
    unsigned char src_mac[6];//源mac地址--source mac
    unsigned short type;//类型
};

struct ip_hread
{
    unsigned char vers:4;//版本--versions
    unsigned char h_len:4;//首部长度--hread length
    unsigned char s_type;//服务类型--serve type
    unsigned char t_len[2];//总长度--total length
    unsigned char tag[2];//标识
    unsigned short sign:3;//标志
    unsigned short offset:13;//片偏移
    unsigned char ttl;//生存时间
    unsigned char p_type;//协议类型--protocol type
    unsigned char h_checksum[2];//头部校验和--hread checksum
    unsigned char src_ip[4];//源ip--source ip
    unsigned char dest_ip[4];//目标ip--destination ip
   // unsigned int option;//选项
};

struct arp_hread
{   
    unsigned char h_type[2];//硬件类型--hardware type
    unsigned char p_type[2];//协议类型--protocol type
    unsigned char h_len;//硬件类型长度--hardware length
    unsigned char p_len;//协议地址长度--protocol length
    unsigned short opcode;//操作码
    unsigned char src_mac[6];//源mac地址--source mac
    unsigned char src_ip[4];//源ip--source ip
    unsigned char dest_mac[6];//目标mac地址--destination mac
    unsigned char dest_ip[4];//目标ip--destination ip
};

// struct udp_data
// {
//     unsigned short src_port;//源端口--source port
//     unsigned short dest_port;//目标端口--destination port
//     unsigned short udp_len;//udp长度
//     unsigned short udp_checksum;//udp校验和
//     unsigned char data[buflen];//数据
// };

// struct tcp_data
// {
//     unsigned short src_port;//源端口--source port
//     unsigned short dest_port;//目标端口--destination port
//     unsigned int s_num;//序列号--serial number
//     unsigned int c_num;//确认号--confirmation number
//     unsigned short h_len:4;//头部长度--hread length
//     unsigned short retain:6;//保留
//     unsigned short tcp_type:6;//tcp类型
//     unsigned short w_size;//窗口尺寸--window size
//     unsigned short tcp_checksum;//tcp校验和
//     unsigned short urgent_point;//紧急指针
//     // unsigned int option;//选项
//     unsigned char data[buflen];//数据
// };

// struct icmp_data
// {
//     unsigned char icmp_type;//icmp类型
//     unsigned char icmp_code;//icmp代码
//     unsigned short icmp_checksum;//icmp校验和
//     unsigned short id;//标示符
//     unsigned short s_num;//序列号--serial number
//     // unsigned int option;//选项
// };

struct my_interface
{
    char name[16];//接口名字
    unsigned char ip[4];//接口对应的ip
    unsigned char broadcast_ip[4];//接口对应的广播地址
    unsigned char subnet_mask[4];//接口对应的掩码
    unsigned char mac[6];//接口对应的mac地址
    unsigned int  flag;//接口当前状态值
};



int sockfd;//原始套接字描述符,在main函数里面初始化
int interface_count;//本机接口总数,在get_interface函数里面初始化
struct my_interface Intf[maxinterfaces];//本机每个接口的参数,在get_interface函数里面初始化




#endif